#ifndef LIRCONN_H
#define LIRCONN_H

#include "progconn.h"

#define APP1		(uint8)'L'
#define APP2		(uint8)'R'

#define GAMEID	9				// Let 'Em Ride
#define MACHID	(uint8)0		// Let 'Em Ride only has one "machine"

class LIRGame;
class LIRHand;

class LIRConnection : public ProgressiveConnection
{
	public:
		LIRConnection(ProgressiveServer* server, SOCKET client);
		~LIRConnection();

		void msgStart();
		void msgAdd(uint8 Byte);
		void msgAdd(int32 SignedLong);
		uint8* msgGetBuf();
		void msgReleaseBuf(int32 Amt);
		void msgEnd();

		bool8	trackGetBalance(int32 *);
		int32	trackAdjustBalance(int32);	// + increases  - decreases
		bool8	trackGetPlayerLimits(int32* minBet, int32* maxBet,
					int32* compFactor);
		bool8	trackNewGame(int32 Bet, int32 progresssiveBet, int32 multiBankBet, 
					int32* Balance);
		bool8	trackDeal(int32 nDeckSeed, int32 numPlayer, uint8* player);         // kharmon.  10-16-06.  #8226.
		bool8	trackTurnOneDone(bool8 Raised1, LIRHand* Dealer);    // kharmon.  11-07-06.  #8226.
		bool8	trackGameDone(bool8 Raised2, int32 payouts[3], int32 payProgressive,
					int32 payMultiBank, int32 Outcome, int32 BalAdjust, bool8 bMalfunction,     // kharmon.  01-05-06.  #4250.
                    int32 *Balance, LIRHand* Dealer, LIRHand* Player);  // kharmon.  10-16-06.  #8226.

		bool8	trackHasSavedGame(int32 *err);
		bool8	trackRemoveSavedGame();
		bool8	trackSaveGame();
        bool8   trackGetOptions();
		int32	trackValidateLogin();
		int32	trackValidateSession();

		// CSN-7075: New Authentication
		void	trackLogoutSession(); 

        uint8   getPayTable();
        uint8   getProgressivePayTable();
		void	SendWinMail(int32 win, int32 jackpotAmount);
		int32	getProgressiveFixedAmountMultiplier();

        #ifdef FORCEDSHOE 
        String  GetPID() {return m_pid;}
        #endif


	protected:
        bool8   getForRealFlag();
		bool8	getResponse();

		void	handleLogin(int32 length, int32 err);

		void	sendStopMsg();

		bool8	parseCasinoLogin(int32, int32*);
		bool8	parseUnicodeCasinoLogin(int32, int32*);

		void	removeCasinoSpecific();
		void	setProgressiveFixedAmountMultiplier(int32 progressiveFixedAmountMultiplier);

		int32	encode(uint8*, uint8*, int32);
		int32	decode(uint8*, uint8*, int32);

		int32	msgRemove(uint8*, int32*);

		// Flash server scalability
		void allocateXMLTranslator( XMLTranslator** target );

	public:
		void	gameDone();

	protected:
		int32 loggedOn;
		LIRGame* game;
		void* casinoSpecific;
		int32 minBet, maxBet;
		int32 compFactor;
		int32 msglen;
		uint8 msgbuf[256];

        uint8 payTable, progPayTable;
		int32 progFixedAmountMultiplier;

        #ifdef FORCEDSHOE       //RPF 20100317 When forcing the shue now filter by pid
        String  m_pid;
        #endif


	// [AO 2008-01-16] Refactoring for HA
	private:
		bool ValidateSession();
};

inline 
int32
LIRConnection::getProgressiveFixedAmountMultiplier()
{
	return progFixedAmountMultiplier;
}

inline
uint8
LIRConnection::getProgressivePayTable()
{
	return progPayTable;
}

inline
uint8
LIRConnection::getPayTable()
{
	return payTable;
}

#endif
